package cn.buddha.jerec.consumer.controller;

import cn.buddha.jerec.consumer.feign.JerecProviderFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName ConsumerController
 * @Author 友野浩二
 * @Description 服务消费者controller测试类
 * @Version 1.0
 */
@RestController
@Slf4j
public class ConsumerController {

    @Autowired
    private JerecProviderFeign jerecProviderFeign;

    @RequestMapping(method = RequestMethod.GET, value = "/client")
    public String consumerHello() {
        log.info("ConsumerController.consumerHello starting...");
        // 这里的使用本地Java API的方式调用远程的Restful接口
        String tongProvider = this.jerecProviderFeign.loveAnswer("shihao");
        return "通过feign调用远程服务tong-eureka-provider的restful接口/loveanswer的结果: ".concat(tongProvider);
    }

}
